﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Test
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            AppDomain.CurrentDomain.UnhandledException   +=   new   UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); 
            Application.ThreadException   +=   new   System.Threading.ThreadExceptionEventHandler(Application_ThreadException); 
            //SystemEvents.SessionEnding   +=   new   SessionEndingEventHandler(SystemEvents_SessionEnding); 

            Application.EnableVisualStyles(); 
            Application.SetCompatibleTextRenderingDefault(false); 
            Application.Run(new   Form1()); 

        } 

                //static   void   SystemEvents_SessionEnding(object   sender,   SessionEndingEventArgs   e) 
                //{ 
                //         throw   new   Exception( "The   method   or   operation   is   not   implemented. "); 
                //} 

                static   void   Application_ThreadException(object   sender,   System.Threading.ThreadExceptionEventArgs   e) 
                { 
                        //throw   new   Exception( "The   method   or   operation   is   not   implemented. ");

                    MessageBox.Show("主程序异常  " + e.Exception.ToString());
                } 

                static   void   CurrentDomain_UnhandledException(object   sender,   UnhandledExceptionEventArgs   e) 
                { 
                        //throw   new   Exception( "The   method   or   operation   is   not   implemented. ");
                    MessageBox.Show("线程异常  " + e.ExceptionObject.ToString());
                }
    
    }
}
